<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../resources/multiple-fields-ax-aria-attributes.js"></script>
</head>
<body>
<input id="test" type="date" aria-label="TestLabel" title="TestTitle">
<script>
var testInput = document.getElementById('test');

test(function(t) {
    testInput.focus();
    assert_equals(focusedElementDescription(),
                  'Month TestLabel, mm, "", TestTitle, intValue:0, range:1-12');
    eventSender.keyDown('\t');
    assert_equals(focusedElementDescription(),
                  'Day TestLabel, dd, "", TestTitle, intValue:0, range:1-31');
    eventSender.keyDown('\t');
    assert_equals(focusedElementDescription(),
                  'Year TestLabel, yyyy, "", TestTitle, intValue:0, range:1-275760');
    eventSender.keyDown('\t', ['shiftKey']);
    eventSender.keyDown('\t', ['shiftKey']);
}, 'Initial empty state');

test(function(t) {
    testInput.focus();
    testInput.value = "2012-10-09";
    assert_equals(focusedElementDescription(),
                  'Month TestLabel, mm, "10", TestTitle, intValue:10, range:1-12');
    eventSender.keyDown('\t');
    assert_equals(focusedElementDescription(),
                  'Day TestLabel, dd, "09", TestTitle, intValue:9, range:1-31');
    eventSender.keyDown('\t');
    assert_equals(focusedElementDescription(),
                  'Year TestLabel, yyyy, "2012", TestTitle, intValue:2012, range:1-275760');
}, 'Non-empty value');

test(function(t) {
    eventSender.keyDown('Backspace');
    assert_equals(focusedElementDescription(),
                  'Year TestLabel, yyyy, "", TestTitle, intValue:0, range:1-275760');
    eventSender.keyDown('\t', ['shiftKey']);
    eventSender.keyDown('Backspace');
    assert_equals(focusedElementDescription(),
                  'Day TestLabel, dd, "", TestTitle, intValue:0, range:1-31');
    eventSender.keyDown('\t', ['shiftKey']);
    eventSender.keyDown('Backspace');
    assert_equals(focusedElementDescription(),
                  'Month TestLabel, mm, "", TestTitle, intValue:0, range:1-12');
}, 'Empty value');
</script>
</body>
</html>
